home *** CD-ROM | disk | FTP | other *** search
- ;************************************************************************
- ;* *
- ;* Icon Colorizer title: *
- ;* *
- ;************************************************************************
-
- Include EquIP.txt ; includes SysEqu.D
- Include Traps.txt
- Include ToolEqu.d
- Include SysErr.d
- Include PackMacs.txt
- Include MacPlusEqu.txt
- Include FSEqu.d
- Include QuickEqu.d
-
- Include 68K-Macros.asm
-
- ;************************************************************************
- ;* *
- ;* INIT Resource *
- ;* *
- ;************************************************************************
-
- RESOURCE 'INIT' 127 'ColorIcons' 80 ; locked, unpurgeable, system heap
-
- SAVE_ALL
-
- ; If shift key or mouse button down or non-color Mac, skip it.
- bsr RunQual
- tst d0
- bne InitFail1
-
- ; load the main code resource
- clr.l -(sp) ; space for result
- move.l #'PaTc',-(sp) ; type
- move #127,-(sp) ; ID
- _GetResource ; load it in
- move.l (sp)+,a3 ; handle to resource
- cmpa.l #0,a3 ; is the handle NIL?
- beq InitFail4 ; exit on fail
-
- move.l a3,-(sp) ; save handle for _DetachResource
- move.l (a3),a3 ; get pointer to resource
- jsr (a3) ; jump to it to install
- move d0,d7 ; save result
-
- _DetachResource ; the code stays around even after our INIT
- ; file is closed.
-
- tst d7
- bne initFail5
- move #goodIconID,d7 ; show "good" icon
- bsr plotIcon
-
- ; check to see if patch has set its memory-full
- ; flag.
- move ipMemFull-Install(a3),d0
- tst d0
- beq initDone ; no - exit normally.
-
- move #ramFullIconID,d7 ; show "Ram Full" icon
- bsr plotIcon
-
- ; Now, we attempt to fix the Ram Full error for next time.
- ;
- clr.l -(sp) ; space for return value
- move.l #'sysz',-(sp) ; type 'sysz'
- clr -(sp) ; id = 0
- _GetResource
- move.l (sp)+,a2 ; gets handle
- move.l a2,d0 ; test for NIL handle
- tst.l d0
- beq @1
- move.l (a2),a0 ; gets pointer
- move.l a0,d0 ; test for NIL master pointer
- tst.l d0
- beq @1
-
- move.l ipMemWant-Install(a3),d0 ; Get estimate
- and.l #$ffffff,d0
- add.l #SYSZ_EXCESS,d0
- add.l #CICN_EXTRA,d0
- move.l d0,(a0) ; a0 still points to sysz's data
-
- move.l a2,-(sp)
- _ChangedResource
-
- clr -(sp)
- _ResError
- move (sp)+,d0
- tst d0
- bne @1
-
- move.l a2,-(sp)
- _WriteResource
- @1:
- bra initDone
-
- InitFail1:
- bra InitFail
-
- InitFail4:
- move #Error4ID,d6
- bra InitFail
-
- InitFail5:
- move ipError-Install(a3),d6 ; Get error code from install code
- bra InitFail
-
- InitFail
- move #badIconID,d7 ; show "not installed" icon
- bsr plotIcon
-
- move d6,d7
- bsr plotIcon
-
- initDone:
- RESTORE_ALL
- rts ; all done
-
- ;
- ; Subroutine to figure out if shift key or mouse button is down.
- ;
- ; Out:
- ; d0 Zero unless error
- ; d6 Contains error Icon ID #
- ;
- myKeyMap equ -16
-
- RunQual:
- link a6,#myKeyMap
-
- tst ROM85
- blt rqRtn1
-
- btst.b #6,ROM85 ; has color quickdraw?
- bne rqRtn2 ; no - blow it off.
-
- subq #2,sp
- _Button
- tst.b (sp)+
- bne.s rqRtn3
-
- pea myKeyMap(a6)
- _GetKeys
-
- btst #0,myKeyMap+7(a6) ; test 56th bit in the keymap
- bne.s rqRtn3 ; (which is the shift key)
-
- moveq #0,d0
- bra.s rqBack
- rqRtn1:
- move #Error1ID,d6
- bra rqerr
- rqRtn2:
- move #Error2ID,d6
- bra rqerr
- rqRtn3:
- move #Error3ID,d6
- bra rqerr
- rqerr:
- moveq #1,d0
- rqBack:
- unlk a6
- rts
-
-
- ; subroutine to plot our ICN# on the screen.
- ;
- ; in:
- ; d7.w icon ID number
- ; out:
- ; all registers unchanged
- ;
- ; This subroutine loads in a CODE resource containing the ShowINIT procedure,
- ; whose interface is as follows:
- ;
- ; PROCEDURE ShowINIT(iconID: Integer; moveX: Integer); EXTERNAL
- ;
- plotIcon:
- SAVE_ALL
-
- clr.l -(sp)
- move.l #'PROC',-(sp) ; resource type
- move #showInitID,-(sp)
- _GetResource
- move.l (sp)+,a3 ; get handle to ShowInit routine
- move.l a3,d0 ; NIL means GetResource failed
- tst.l d0
- beq piGiveUp
-
- move.l (a3),a3 ; get pointer to ShowInit routine
- move.l a3,d0 ; NIL means it's been purged!
- tst.l d0
- beq piGiveUp
-
- move d7,-(sp) ; icon ID
- move #-1,-(sp) ; moveX
- jsr (a3) ; call ShowInit routine
-
- move.l a3,-(sp) ; Now, get rid of the code resource.
- _ReleaseResource
-
- piGiveUp:
-
- RESTORE_ALL
- rts
-
- ;====================================================================
- ; This is the end of the INIT resource
- ;====================================================================
-
- RESOURCE 'PaTc' 127 'ColorIcons' 80 ; Starts out locked, unpurgeable,
- ; system heap
-
- ;************************************************************************
- ;* *
- ;* 'PaTc' Resource *
- ;* Installation Code *
- ;* *
- ;************************************************************************
-
- Install:
- bra Install1
-
- ipMemFull: dc.w 0 ; Flag indicating if icons have filled
- ; the buffer yet.
-
- ipError: dc.w 0 ; Error code return to caller
-
- ipMemWant: dc.l 0 ; This is how much memory we "wished we had"
-
- LABEL 'Install'
- Install1:
- movem.l a0-a5/d1-d6,-(sp)
-
- ; Allocate local storage pointer.
- move.l #mySize,d0
- _NewPtr,SYS+CLEAR
- tst d0
- bne installBad6
- move.l a0,d0
- tst.l d0
- beq installBad6
- lea a4Save(pc),a1
- move.l a0,(a1)
-
- ; Set up a4.
- move.l a0,a4
-
- ; Allocate scratch cicn space
- move.l #MAX_CICN,d0
- _NewHandle,SYS+CLEAR
- tst d0
- bne installBad6
- move.l a0,d0
- tst.l d0
- beq installBad6
- lea scratchCicn(a4),a1 ; save the handle
- move.l a0,(a1)
-
- ; Allocate scratch ctab space
- move.l #MAX_CTAB,d0
- _NewHandle,SYS+CLEAR
- tst d0
- bne installBad6
- move.l a0,d0
- tst.l d0
- beq installBad6
- lea scratchCtab(a4),a1 ; save the handle
- move.l a0,(a1)
-
- ; Allocate scratch cicn image space
- move.l #MAX_IMAGE,d0
- _NewHandle,SYS+CLEAR
- tst d0
- bne installBad6
- move.l a0,d0
- tst.l d0
- beq installBad6
- lea scratchImage(a4),a1 ; save the handle
- move.l a0,(a1)
-
- ; Allocate space to store icons. First get 'sysz' resource to find out
- ; how much we should allocate.
- ;
- clr.l -(sp) ; space for return value
- move.l #'sysz',-(sp) ; type 'sysz'
- clr -(sp) ; id = 0
- _GetResource
- move.l (sp)+,a0 ; gets handle
- move.l a0,d0 ; test for NIL handle
- tst.l d0
- beq installBad7
- move.l (a0),a0 ; gets pointer
- move.l a0,d0 ; test for NIL master pointer
- tst.l d0
- beq installBad7
-
- move.l (a0),d0 ; gets size
- sub.l #SYSZ_EXCESS,d0
- ble installBad8 ; test for less than zero left
- move.l d0,d7 ; save for later
-
- _NewPtr,SYS+CLEAR ; allocate it
- tst d0
- bne installBad9
- move.l a0,d0
- tst.l d0
- beq installBad9
-
- ; Initialize linked-list of icons.
- lea HeadPointer(a4),a1 ; Set head pointer.
- move.l a0,(a1)
-
- clr.l (a0) ; Set "next" pointer of first icon.
-
- lea TailPointer(a4),a1 ; Init tail pointer.
- move.l a0,(a1)
-
- add.l d7,a0 ; init ptr to end of storage
- lea EndOfStorage(a4),a1
- move.l a0,(a1)
-
- ; Install patches
- bsr PInstall
-
- ; Do a GetResource on all ICN#'s in the current resource file. This makes the
- ; patch load in color icons from the INIT file, thereby letting people define
- ; color icon aliases without modifying other files.
- clr -(sp)
- move.l #'ICN#',-(sp)
- dc.w $A80D ; _Count1Resources
- move (sp)+,d7 ; number of resources in d7
-
- loadIconLoop:
- tst d7 ; any more icons?
- ble installOK ; no - quit.
-
- clr.l -(sp)
- move.l #'ICN#',-(sp)
- move d7,-(sp)
- dc.w $A80E ; _Get1IxResource
- move.l (sp)+,a0
-
- move.l a0,d0 ; test for errors
- tst.l d0
- beq liNext
- tst.l (a0)
- beq liNext
-
- move.l a0,-(sp) ; resource handle
- pea scratchID(a4)
- pea scratchType(a4)
- pea scratchName(a4)
- _GetResInfo ; find out ID
-
- clr.l -(sp) ; now get the resource again, accessing it
- ; by its ID.
- move.l #'ICN#',-(sp)
- move scratchID(a4),-(sp)
- _GetResource
- move.l (sp)+,a0
-
- move.l a0,-(sp) ; release the resource
- _ReleaseResource
-
- liNext: subq #1,d7
- bra loadIconLoop
-
- installOK:
- moveq #0,d0
-
- installDone:
- tst.w d0
- movem.l (sp)+,a0-a5/d1-d6
- rts
-
- installBad6:
- lea ipError(pc),a0 ; Indicate Error 6 to INIT code.
- move #Error6ID,(a0)
- bra installErr
-
- installBad7:
- lea ipError(pc),a0 ; Indicate Error 7 to INIT code.
- move #Error7ID,(a0)
- bra installErr
-
- installBad8:
- lea ipError(pc),a0 ; Indicate Error 8 to INIT code.
- move #Error8ID,(a0)
- bra installErr
-
- installBad9:
- lea ipError(pc),a0 ; Indicate Error 9 to INIT code.
- move #Error9ID,(a0)
-
- installErr:
- moveq #-1,d0
- bra installDone
-
- ; end of install.asm
-
-
- .align 2
-
- a4Save dc.l 0 ; place to save value of A4 for our local
- ; storage.
-
- PGRSave dc.l 0 ; trap address for GetResource before we
- ; patched it.
- PPISave dc.l 0 ; trap address of PlotIcon before we patched
- ; it.
- PCBSave dc.l 0 ; trap address of CopyBits before we patched
- ; it.
-
- ;************************************************************************
- ;* *
- ;* Patches *
- ;* *
- ;************************************************************************
-
- PLocals dc.l 0 ; save locals
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; [P.Install] - install the trap patches.
- ;
- ; In: a4 -> tape cache local storage
- ;
- ; Out: all registers unchanged
- ; GetResource - patched
- ; PlotIcon - patched
- ; CopyBits - patched
- ; PGRSave(pc) - gets old trap address
- ; PPISave(pc) - gets old trap address
- ; PCBSave(pc) - gets old trap address
- ; PLocals(pc) - gets a4 for future use
- ;
- ; Notes:
- ; 1) GetIcon doesn't have to be patched because it calls GetResource.
- ;
- ; 2) Patching both PlotIcon and CopyBits is redundant, but since the patch
- ; to PlotIcon is cleaner, it is desirable to have both installed.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- LABEL 'PInstall'
- PInstall:
- SAVE_ALL
-
- ; set up a4
- move.l a4save(pc),a4
-
- ; patch the GetResource trap
- move #GRTrap,d0
- _GetTrapAddress
- lea PGRSave(pc),a1
- move.l a0,(a1) ; save old address
- move #GRTrap,d0
- lea PGetResource(pc),a0
- _SetTrapAddress
-
- ; patch the PlotIcon trap
- move #PITrap,d0
- _GetTrapAddress
- lea PPISave(pc),a1
- move.l a0,(a1) ; save old address
- move #PITrap,d0
- lea PPlotIcon(pc),a0
- _SetTrapAddress
-
- ; patch the CopyBits trap
- move #CBTrap,d0
- _GetTrapAddress
- lea PCBSave(pc),a1
- move.l a0,(a1) ; save old address
- move #CBTrap,d0
- lea PCopyBits(pc),a0
- _SetTrapAddress
-
- RESTORE_ALL
- rts
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; P.Get.Resource - Patch to GetResource
- ;
- ; This patch intercepts GetResource calls. It works in the following manner:
- ;
- ; if (type is not ICN#)
- ; dispatch
- ; save parameters;
- ; call original GetResource to load in the corresponding 'cicn'
- ; if error
- ; restore parameters
- ; dispatch
- ; save 'cicn' in our icon-storage area
- ; if not enough room left in our storage area
- ; restore parameters
- ; dispatch
- ; restore parameters
- ; get return address from stack
- ; call original GetResource to get the actual icon
- ; if it didn't succeed
- ; place return value on stack
- ; return to original return address
- ; search for this ICN# - if already in our table, then
- ; place return value on stack
- ; return to original return address
- ; save ICN# in our storage area
- ; update next and tail pointers
- ; place return value on stack
- ; return to original return address
- ;
- ; The stack for a GetResource call looks like this:
- ;
- ; A6 4(A6) 8(A6) 10(A6) 14(A6)
- ; | | | | |
- ; Stack grows --+-----------+-----------+-----+-----------+-----------+---
- ; <-- this way | Old A6 | Rtrn Adrs | ID | ResType | Rtrn Value|
- ; --+-----------+-----------+-----+-----------+-----------+---
- ;
- ; Note:
- ; We go out of our way to make sure that the 'cicn' GetResource call is
- ; done before the 'ICN#' GetResource call. This is to try and make sure that
- ; the value of ResError makes sense to the application.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- PGetResource:
- link a6,#0
-
- ; if (type is not ICN#), dispatch
- compare_l 10(a6),#'ICN#'
- bne PGRQuickExit
-
- ; Setup a4
- movem.l d0-d7/a0-a4,-(sp)
- move.l a4save(pc),a4
-
- ; save parameters
- move 8(a6), ResID(a4)
- move.l 10(a6), ResType(a4)
-
- ; call original GetResource to load in the corresponding 'cicn'
- clr.l -(sp) ; space for return
- move.l #'cicn',-(sp)
- move ResID(a4),-(sp)
- move.l PGRSave(pc),a0
- jsr (a0)
- move.l (sp)+,a0 ; get handle
-
- ; if error
- ; restore parameters
- ; dispatch
- move.l a0,d0
- tst.l d0
- beq PGRErr1 ; NIL handle
- tst.l (a0)
- beq PGRErr1 ; Handle points to NIL pointer
-
- move.l a0,cicnHandle(a4) ; Save it for later when we have to
- ; do a ReleaseResource on it.
-
- ; At this point we've gotten the resource, so it looks like we'll load
- ; both it and the ICN# and add 'em to our internal table. So, we get the
- ; handle size (something we need to know anyway) and add it, plus
- ; CICN_OFFSET to our estimate of how much memory we'd "like" to have.
- ;
- _GetHandleSize
- lea ipMemWant(pc),a0 ; Add cicn size + CICN_OFFSET to estimate
- add.l d0,(a0)
- add.l #CICN_OFFSET,(a0)
- tst.l d0 ; Now test for error...
- beq PGRErr1b ; GetHandleSize returned error
-
- ; if not enough room left in our storage area, dispatch
- ;
- move.l d0,cicnSize(a4) ; save this for later.
-
- move.l TailPointer(a4),a2 ; get current tail pointer
- adda.l d0,a2 ; add length of 'cicn'
- adda.l #CICN_OFFSET,a2 ; and length of other data
- adda.l #PS_PADDING,a2 ; fudge to be safe
- move.l EndOfStorage(a4),a3
- compare_l a2,a3
- bge PGRErr1b ; not enough room -- blow it off!
-
- ; save "cicn" in our icon-storage area
- ;
- move.l cicnHandle(a4),a0 ; get handle to 'cicn' again
- move.l (a0),a0 ; get pointer to color icon
- move.l TailPointer(a4),a1 ; Get tail pointer in a1
- adda.l #CICN_OFFSET,a1 ; offset for 'cicn'
- ; ; length still in d0
- _BlockMove
- tst d0
- bne PGRErr1b
-
- ; call original GetResource to get the actual icon
- ;
- clr.l -(sp) ; space for return
- move.l ResType(a4),-(sp)
- move ResID(a4),-(sp)
- move.l PGRSave(pc),a0
- jsr (a0)
- move.l (sp)+,a0 ; get handle
- lea icnHandle(a4),a1
- move.l a0,(a1)
-
- move.l a0,d0 ; test for error.
- tst.l d0
- beq PGRErr2 ; NIL handle.
- tst.l (a0)
- beq PGRErr2 ; Handle points to NIL.
-
- ; search for this ICN# - if already in our table, then
- ; place return value on stack
- ; return to original return address
- clr.l -(sp) ; space for return value
- move.l (a0),a0 ; get 'ICN#' pointer
- move.l a0,-(sp) ; push it
- bsr PGRLookup ; search
- move.l (sp)+,a0 ; get result
- move.l a0,d0 ; check for NIL
- tst.l d0
- bne PGRErr2 ; already in table -- return right away.
-
- ; save ICN# in our storage area
- move.l icnHandle(a4),a0 ; get 'ICN#' handle back
- move.l (a0),a0 ; get pointer
- move.l TailPointer(a4),a1
- adda.l #ICN_OFFSET,a1
- move.l #ICN_LENGTH,d0
- _BlockMove
- tst d0
- bne PGRErr2
-
- ; update next and tail pointers
- move.l TailPointer(a4),a1
- move.l a1,a2
- adda.l #CICN_OFFSET,a2 ; add length of pointer and 'ICN#'
- move.l cicnSize(a4),d0
- addq.l #1,d0 ; round up to an even number (if
- and.l #$fffffffe,d0 ; necessary)
- adda.l d0,a2 ; add length of 'cicn'
-
- move.l a2,(a1) ; fill in next field of the record
- ; we just created.
- move.l a2,TailPointer(a4) ; this is the new tailpointer.
- clr.l (a2) ; NIL out the next record's next field.
-
- ; We have to to return to the caller without dispatching through GetResource.
- ; We do this by copying the return address to a different place on the stack
- ; and offsetting the SP by +6 to discard the unwanted parameters.
- ;
- PGRErr2:
- move.l cicnHandle(a4),-(sp) ; Release the 'cicn' we loaded.
- _ReleaseResource
- move.l icnHandle(a4),14(a6) ; Place return value on stack in
- ; correct place.
- move.l 4(a6),10(a6) ; copy their return address to a position right
- ; below this return value.
- movem.l (sp)+,d0-d7/a0-a4 ; restore regs
- unlk a6 ; restore a6
- lea 6(sp),sp ; discard 6 bytes worth of stack (corresponds
- ; to the 6 bytes of parameters that our
- ; original call had.)
- rts ; return to original return address, leaving
- ; return value in place.
-
-
- ; These three exit points dispatch to the original GetResource by pushing the
- ; trap's original address onto the stack and doing an RTS. This makes the
- ; PC jump to the beginning of the original patch with all of the parameters,
- ; etc. set up just the way they were when we were called.
- ;
- PGRQuickExit:
- unlk a6
- move.l PGRSave, -(sp)
- rts
-
- PGRErr1b:
- move.l cicnHandle(a4),-(sp) ; Release the 'cicn' we loaded.
- _ReleaseResource
-
- lea ipMemFull(pc),a0 ; Set ram-full flag so install code
- move #1,(a0) ; can see it.
- PGRErr1:
- movem.l (sp)+,d0-d7/a0-a4
- unlk a6
- move.l PGRSave, -(sp)
- rts
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; PGRL.Lookup - Find ICON (if present) in our table
- ;
- ; This routine looks through our icon storage record for the given icon; if
- ; a match is found it returns a pointer to the ICON/cicn record. Otherwise
- ; returns NIL.
- ;
- ; It is stack-based; its prototype is:
- ;
- ; pascal longword PGRLLookup(Pointer ih);
- ;
- PGRLookUp:
- STACK_DECLARE
- LONG_PARAM ih ; handle to ICON
- STACK_BEGIN
-
- SAVE_ALL
-
- clr.l d0 ; clear return value for starters.
- move.l d0,(a6)
-
- move.l a4save,a4
-
- move.l HeadPointer(a4),a2 ; points to first ICON/cicn record
-
- PGRLTry:
- move.l (a2),d0 ; test current record's next pointer: is it
- tst.l d0 ; NIL?
- beq PGRLDone ; ...then this record is unused and there are
- ; no more icons.
-
- move.l parm_ih(a6),a3 ; get pointer to ICON
-
- lea ICN_OFFSET(a2),a1 ; points to ICON
- move #(ICN_LENGTH/4)-1,d7
- @1: compare_l (a1)+, (a3)+ ; compare 4 icon bytes
- bne PGRLTryNext ; differ! This icon is not a match.
- dbf d7,@1 ; loop back and try next longword.
-
- PGRLFound:
- move.l a2,(a6) ; return pointer to ICON/cicn record.
- bra PGRLDone
-
- PGRLTryNext:
- move.l (a2),a2 ; go to next ICON/cicn record.
- bra PGRLTry ; loop back to test it.
-
- PGRLDone:
- RESTORE_ALL
- STACK_END
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; P.Plot.Icon - Patch to PlotIcon
- ;
- ; This patch intercepts PlotIcon calls. It works in the following manner:
- ;
- ; call GetPort and check the rowbytes, # of bits, etc.
- ; if rowBytes has high 3 bits clear, then
- ; dispatch
- ; if # of bits is less than 4
- ; dispatch
- ;
- ; search for ICN# in our table
- ; if not found
- ; dispatch
- ; call PlotCIcon
- ;
- ; The stack for a PlotIcon call looks like this:
- ;
- ; A6 4(A6) 8(A6) 12(A6)
- ; | | | |
- ; Stack grows --+-----------+-----------+-----------+-----------+---
- ; <-- this way | Old A6 | Rtrn Adrs | Icon Hdl | Rect Ptr |
- ; --+-----------+-----------+-----------+-----------+---
- ;
- ; Notes:
- ; 1) This patch has a known bug: it passes a "fake handle" to PlotCIcon. This
- ; bug can be fixed (if necessary) by having the install code allocate a handle,
- ; then have this patch copy the cicn data into this "scratch buffer" and pass
- ; the handle to the scratch buffer to PlotCIcon.
- ;
- ; 2) The GetPort checking is currently not done. This means that the patch
- ; will still be acting if the monitor is set to 1 or 2 bits. Since PlotIcon
- ; uses the B/W icon automatically in this case, it's not really a problem --
- ; it just makes drawing a bit slower because of the overhead of this code.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- PPlotIcon:
- link a6,#0
- movem.l d0-d7/a0-a4,-(sp)
-
- move.l a4save(pc),a4
-
- clr.l -(sp) ; space for return value
- move.l 8(a6),a0 ; ICN# handle
- move.l (a0),-(sp) ; push pointer
- bsr PGRLookup
- move.l (sp)+,a0 ; get result
- move.l a0,d0 ; is it NIL?
- tst.l d0
- beq PPIErr1 ; yep, no color icon, so dispatch.
-
- adda.l #CICN_OFFSET,a0 ; get ptr to cicn
- move.l 12(a6),-(sp) ; use the rect ptr that they gave us
- move.l a0,-(sp) ; pointer to cicn resource structure
- clr -(sp) ; SrcCopy mode
- bsr PCBPlotIt
-
- ; Exit point for returning without dispatching.
- ;
- PPIErr2:
- move.l 4(a6),12(a6) ; copy their return address to top 4 bytes of
- ; original parameters.
- movem.l (sp)+,d0-d7/a0-a4 ; restore regs
- unlk a6 ; restore a6
- lea 8(sp),sp ; discard 8 bytes worth of stack (corresponds
- ; to the 8 bytes of parameters that our
- ; original call had.)
- rts ; return to original return address.
-
- ; Exit point for dispatching to PlotIcon
- ;
- PPIErr1:
- movem.l (sp)+,d0-d7/a0-a4
- unlk a6
- move.l PPISave, -(sp)
- rts
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; P.CopyBits - Patch to CopyBits
- ;
- ; This patch intercepts CopyBits calls. It works in the following manner:
- ;
- ; call GetPort and check the rowbytes, # of bits, etc.
- ; if rowBytes has high 3 bits clear, then
- ; dispatch
- ; if # of bits is less than 4
- ; dispatch
- ;
- ; if MaskRgn not NIL then dispatch
- ; if mode == srcBic or mode == notSrcBic then dispatch
- ; if srcRect not equal to (0,0,32,32) then dispatch
- ; if srcBits rowBytes not equal to 4 then dispatch
- ; if srcBits bounds not equal to (0,0,32,32) then dispatch
- ;
- ; search for ICN# in our table
- ; if not found
- ; dispatch
- ; call PlotCIcon
- ;
- ; The stack for a CopyBits call looks like this:
- ;
- ; A6 4(A6) 8(A6) 12(A6) 14(a6)
- ; | | | | |
- ; Stack grows --+---------+---------+---------+----+---------+-/
- ; <-- this way | Old A6 |Rtrn Adrs| maskRgn |mode| dstRect | \
- ; --+---------+---------+---------+----+---------+-/
- ;
- ; 18(a6) 22(a6) 26(a6)
- ; | | |
- ; /-+---------+---------+---------+---
- ; \ | srcRect | dstBits | srcBits |
- ; /-+---------+---------+---------+---
- ;
- ; Notes:
- ; 1) See note 1) in PPlotIcon above.
- ;
- ; 2) See note 2) in PPlotIcon above.
- ;
- ; 3) CopyBits must be patched to get color icons in the Finder. Apparently,
- ; the Finder uses CopyBits instead of PlotIcon for two reasons:
- ; 1. They occasionally have to create their own off-screen bitmap for the
- ; purposes of (among other things) creating dimmed icons and creating
- ; the gray outline of the mask for dragging icons.
- ; 2. PlotIcon calls are ignored when printing. In other words, they are not
- ; caught by the bottleneck proc that captures picture data between
- ; PrOpenPage and PrClosePage.
- ;
- ; 4) There are certain situations in which this patch will get fooled by a
- ; CopyBits call that is not really an icon. This will happen, for example, if
- ; (in MacPaint) you select an area exactly 32x32 pixels in size which contains
- ; an image exactly identical to that in one of our icons and drag it with the
- ; mouse. Since such an occurrance is rare (except when done deliberately) I
- ; deem the bug acceptable.
- ; In fact, I couldn't even duplicate the bug deliberately, although I
- ; tried in several popular applications.
- ; We could fix this bug by checking the current application name (to see if
- ; it's the Finder) but this would not work under MultiFinder.
- ;
- ; 5) There is a potential problem with printing. This patch replaces CopyBits
- ; calls with PlotCIcon calls. Because PlotCIcon calls are ignored by the Print
- ; Manager, they will not show up in the printed output. This is not a problem
- ; with black-and-white printers like the 5.0 LaserWriter because we check the
- ; color QuickDraw flags of dstBits, which are clear when printing to a black-
- ; and-white printer. However, with 6.0 LaserWriters it doesn't work, because
- ; the printing port is a CGrafPort.
- ;
- ; 6) We currently plot in color whenever the bits-per-pixel is greater than
- ; one. This generates somewhat crummy results on monitors set to 2 bits
- ; per pixel (four colors), although for most color icons, the results are
- ; always better than the 1-bit-per-pixel alternatives.
- ; Thus, I've decided to leave it this way until someone complains about
- ; it.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- PCopyBits:
- link a6,#0
- movem.l d0-d7/a0-a4,-(sp)
-
- move.l a4save(pc),a4
-
- ; if MaskRgn not NIL then dispatch
- tst.l 8(a6)
- bne PCBErr1
-
- ; if mode == srcBic or mode == notSrcBic then dispatch
- move 12(a6),d0
- compare d0,#srcBic
- beq PCBErr1
- compare d0,#notSrcBic
- beq PCBErr1
-
- ; if srcBits rowBytes not equal to 4 then dispatch
- move.l 26(a6),a0 ; get srcBits
- move rowBytes(a0),d0 ; get RowBytes
- compare d0,#4
- bne PCBErr1
-
- ; if dstBits is not a color bitmap, dispatch
- move.l 22(a6),a0 ; get dstBits
- move rowBytes(a0),d0 ; get RowBytes
- and #$c000,d0 ; see if it's a portPixMap handle
- compare d0,#$c000
- beq PCBCont1 ; it is -- go ahead.
-
- move rowBytes(a0),d0 ; get RowBytes again
- and #$e000,d0 ; check for color QD bits
- beq PCBErr1 ; no color QD bits set - blow it off!
-
- bra.s PCBCont2
-
- PCBCont1:
- move.l (a0),a0 ; dereference portPixMap handle
- move.l (a0),a0
-
- PCBCont2: ; a0 now points to destination pixMap
-
- ; if dstBits is less than 2 bits per pixel, dispatch. (See note 6
- ; above.)
- move 32(a0),d0 ; get bits-per-pixel
- compare d0, #2
- blt PCBErr1
-
- ; if srcRect not equal to (0,0,32,32) then dispatch
- move.l 18(a6),a0 ; get srcRect ptr
- move.l (a0)+,d0 ; get top left
- bne PCBErr1 ; nonzero - dispatch.
- move.l (a0),d0 ; get bottom right
- compare_l d0,#$200020 ; compare to (32, 32)
- bne PCBErr1 ; no - dispatch.
-
- ; if srcBits bounds not equal to (0,0,32,32) then dispatch
- move.l 26(a6),a0 ; get srcBits
- lea bounds(a0),a0
- move.l (a0)+,d0 ; get top left
- bne PCBErr1 ; nonzero - dispatch.
- move.l (a0),d0 ; get bottom right
- compare_l d0,#$200020 ; compare to (32, 32)
- bne PCBErr1 ; no - dispatch.
-
- ; search for ICN# in our table
- ; if not found, dispatch
- ; call PlotCIcon
- move.l 26(a6),a0 ; get srcBits again
- clr.l -(sp) ; space for return value
- move.l (a0),-(sp) ; push baseAddr of source bitmap
- bsr PGRLookup
- move.l (sp)+,a0 ; get result
- move.l a0,d0 ; is it NIL?
- tst.l d0
- beq PCBErr1 ; yep, no color icon, so dispatch.
-
- adda.l #CICN_OFFSET,a0 ; get ptr to cicn
- move.l 14(a6),-(sp) ; use the dstRect that they gave us
- move.l a0,-(sp) ; pointer to cicn resource structure
- move 12(a6),-(sp) ; transfer mode
- bsr PCBPlotIt
-
- ; Exit point for returning without dispatching.
- ;
- PCBErr2:
- move.l 4(a6),26(a6) ; copy their return address to top 4 bytes of
- ; original parameters.
- movem.l (sp)+,d0-d7/a0-a4 ; restore regs
- unlk a6 ; restore a6
- lea 22(sp),sp ; discard 22 bytes worth of stack (corresponds
- ; to the 22 bytes of parameters that our
- ; original call had.)
- rts ; return to original return address.
-
- ; Exit point for dispatching to CopyBits
- ;
- PCBErr1:
- movem.l (sp)+,d0-d7/a0-a4
- unlk a6
- move.l PCBSave, -(sp)
- rts
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; PCB.PlotIt - set up cicn structures and call PlotCIcon
- ;
- ; This routine takes a pointer to an ICON/cicn record and plots the cicn
- ; on the screen, given a rectangle. Since the cicn portion of the record is
- ; still in its "raw" cicn resource format, the first steps involve "parsing
- ; out" the fields of the 'cicn' resource data. This resource structure is
- ; documented in Inside Mac, vol. 5, pages 80-81.
- ; Here's the pseudo-code for this routine:
- ;
- ; compute icon height in pixels
- ; compute offsets for MaskData and BMapData, and total length of everything
- ; up to the end of the BMapData
- ; if too long, dispatch
- ; compute offset and length of PMapCTab
- ; if color table too big, dispatch
- ; compute offset and length for cicn image data
- ; if cicn image data too large, dispatch
- ; copy cicn image data into scratch image space
- ; copy color table data into scratch ctab space
- ; copy rest of it into scratch cicn space
- ; fill in fields of cicn: cicn BaseAddr, icon PMTable, mask BaseAddr, BMap
- ; BaseAddr, IconData handle
- ; set foreground and background colors
- ; get dstBits and bounds from current port
- ; call CopyBits
- ;
- ; This is a stack-based routine:
- ;
- ; pascal void PCBPlotIt(Pointer the_rect, Pointer the_icon, word mode);
- ;
- ; Notes:
- ; 1) Although this routine handles icons of any pixel-size (not just 32x32),
- ; it assumes that the height of all three icons (B/W icon, mask, and color
- ; icon) is the same. It could be made more robust by looking at the IconMask
- ; and IconBMap bounds rectangles and treating them seperately.
- ;
- ; 2) The CopyBits patch that calls us checks specifically for 32x32 icons.
- ; This means that if our 'cicn' is not 32x32, it will only get plotted on
- ; PlotIcon calls.
- ;
- ; 3) This routine doesn't take the same parameters as CopyBits because it
- ; is called by the PlotIcon patch, which doesn't have all the information
- ; which CopyBits has. Therefore, this routine has to figure out on its own
- ; what the dstBits should be.
- ;
- ; 4) In its original implementation, this routine plotted by calling
- ; PlotCIcon. This required setting up a CIcon record with pointers to
- ; PixMap data, two sets of BitMap data, and a color table. Now that we
- ; use CopyBits to do the drawing, none of this is needed except for the
- ; PixMap (which is the first portion of the CIcon data structure) and
- ; the color table and pixel image to which it points. Thus, some code
- ; has been commented out, and some is somewhat superfluous.
- ;
- PCBPlotIt:
- STACK_DECLARE
- LONG_PARAM rectptr
- LONG_PARAM cicnptr
- WORD_PARAM mode
- STACK_BEGIN
- SAVE_ALL
-
- move.l a4save(pc),a4 ; set up a4
-
- ; compute icon height in pixels (This is used later on in computing data
- ; sizes of bitMaps and pixMaps)
- move.l parm_cicnptr(a6),a3 ; set up pointer to the structure
- move 6+4(a3),d0 ; get PMap bounds bottom
- sub 6(a3),d0 ; subtract bounds top
- move d0,pcbHeight(a4) ; save it
-
- ; compute offsets for MaskData and BMapData, and total length of everything
- ; up to the end of the BMapData
- ; (offset for MaskData is always 82)
- move #82,d0 ; maskdata offset
- move 54(a3),d1 ; get maskdata rowBytes
- and #$1fff,d1 ; mask out color QD bits
- mulu pcbHeight(a4),d1 ; multiply by icon height
- add d1,d0 ; add this.
- move d0,pcbBmapOffset(a4) ; save offset for use later.
-
- move 68(a3),d1 ; get bmap rowBytes
- and #$1fff,d1 ; mask out color QD bits
- mulu pcbHeight(a4),d1 ; multiply by icon height
- add d1,d0 ; add this.
- move d0,pcbCicnLength(a4) ; save length for use later.
-
- ; if too long, dispatch
- compare d0,#MAX_CICN
- bge PCBGiveUp
-
- ; compute offset and length of PMapCTab
- ; (offset is the same as the length we just computed)
- move.l a3,a1 ; get ptr to structure
- adda d0,a1 ; point to color table
- move 6(a1),d0 ; get ctSize
- addq #1,d0 ; add 1
- asl #3,d0 ; multiply by 8
- addq #8,d0 ; add 8 for first three fields
- move d0,pcbCtabLength(a4) ; save it
-
- ; if color table too big, dispatch
- compare d0,#MAX_CTAB
- bge PCBGiveUp
-
- ; compute offset and length for cicn image data
- move 4(a3),d0 ; get pmap rowbytes
- and #$1fff,d0 ; mask out color QD bits
- mulu pcbHeight(a4),d0 ; multiply by icon height
- move d0,pcbImageLength(a4) ; save it
-
- ; if cicn image data too large, dispatch
- compare d0,#MAX_IMAGE
- bge PCBGiveUp
-
- ; copy cicn image data into scratch image space
- move pcbCicnLength(a4),d0 ; get ctab offset
- add pcbCtabLength(a4),d0 ; add ctab size to get image offset
- move.l a3,a0 ; pointer to whole structure
- adda d0,a0 ; now points to cicn image
- move pcbImageLength(a4),d0 ; set up length
- move.l scratchImage(a4),a1 ; image space handle
- move.l (a1),a1 ; get pointer
- _BlockMove
- tst d0
- bne PCBGiveUp
-
- ; copy color table data into scratch ctab space
- move pcbCicnLength(a4),d0 ; get ctab offset
- move.l a3,a0
- adda d0,a0 ; pointer to ctab
- move pcbCTabLength(a4),d0 ; ctab length
- move.l scratchCtab(a4),a1 ; handle to scratch ctab
- move.l (a1),a1 ; pointer
- _BlockMove
- tst d0
- bne PCBGiveUp
-
- ; copy rest of it into scratch cicn space. (Note: we don't actually need
- ; all of this, we really only need the first portion, which becomes the
- ; PixMap. See note 4 above)
- move.l a3,a0 ; pointer to main structure
- move pcbCicnLength(a4),d0 ; length
- move.l scratchCicn(a4),a1
- move.l (a1),a1
- _BlockMove
- tst d0
- bne PCBGiveUp
-
- ; fill in fields of cicn: cicn BaseAddr, icon PMTable, mask BaseAddr, BMap
- ; BaseAddr, IconData handle
- move.l scratchCicn(a4),a1 ; get handle to cicn again
- move.l (a1),a1 ; get pointer
-
- move.l scratchImage(a4),a0
- move.l (a0),a0
- move.l a0,(a1) ; fill in PMap BaseAddr
-
- move.l scratchCTab(a4),a0
- move.l a0,42(a1) ; fill in PMap PMTable
-
- ; We're setting up the mask's bitmap, solely for use in a CopyMask call.
- ; The CopyBits call to the screen doesn't use the mask.
- move.l a1,a0
- adda #82,a0 ; points to mask data
- move.l a0,50(a1) ; fill in IconMask baseAddr
-
- ; These instructions are NOP'ed because they're only necessary for
- ; PlotCIcon, which we no longer use.
- ;
- ; move.l a1,a0
- ; adda pcbBmapOffset(a4),a0 ; points to BMap
- ; move.l a0,64(a1) ; fill in BMap baseAddr
- ;
- ; move.l scratchImage(a4),78(a1) ; fill in IconData handle
- ;
- ; call PlotCIcon. The Pascal interface for this is:
- ; PlotCIcon(r: Rect; icon: cIconHandle);
- ;
- ; move.l parm_rectptr(a6),-(sp) ; rect
- ; move.l scratchCicn(a4),-(sp) ; cicn handle
- ; dc.w $AA1F ; trap word for PlotCIcon
-
- ; Getting the current port to use the bitmap is fine, however, we shouldn't
- ; try to use the current port to get the current ForeColor. This won't work
- ; if the current port is an old-style GrafPort.
- pea curForeColor(a4)
- dc.w $AA19 ; trap word for GetForeColor
-
- pea curBackColor(a4)
- dc.w $AA1A ; trap word for GetBackColor
-
- pea blackRGB(pc)
- dc.w $AA14 ; trap word for RGBForeColor
-
- pea whiteRGB(pc)
- dc.w $AA15 ; trap word for RGBBackColor
-
- pea grayRGB(pc) ; %%% Set a gray opColor
- dc.w $AA21 ; trap word for OpColor
-
- ; Now, we determine if "the icon is selected". This is actually a
- ; determination of what the foreground color is, etc. but in the
- ; Finder this amounts to determining if the icon is selected.
- ;
- ; In the Finder, the ForeColor is white if and only if the icon
- ; is selected.
- ;
- ; Notes:
- ; 1) We also check the transfer mode to see if it's srcCopy. This
- ; is a basic check to try to avoid doing Finder-like drawing in
- ; applications other than the Finder. The Finder seems to always
- ; draw icons in srcOr mode (and masks in srcBic mode).
- ;
- tst parm_mode(a6) ; Transfer mode = SrcCopy?
- beq PCBNotSelected ; NO - don't treat as selected.
-
- move.l curForeColor(a4),d0 ; Test Red and Green
- not.l d0 ; are they both FFFF?
- bne PCBNotSelected ; NO - not selected
- move.w curForeColor+4(a4),d0 ; Test Blue
- not.w d0 ; is it FFFF?
- bne PCBNotSelected ; NO - not selected
-
- lea selected(a4),a0 ; Yup, it's selected.
- move #1,(a0)
- bra PCBlabel1
-
- PCBNotSelected:
- lea selected(a4),a0
- clr (a0)
- bra PCBlabel1
-
- PCBlabel1:
-
- move selected(a4),d0 ; Selected flag TRUE?
- beq PCBCopyBits ; no, use newMul & CopyBits method
-
- ; =============================================
- ; Selected Icon: Blend Color-table and CopyMask
- ; =============================================
- ; If the icon is *selected*, the Finder draws it with a non-white ForeColor.
- ; in this case, we desire the icon to appear on the screen "blended" with
- ; the selected ForeColor (which the Finder has just drawn in the mask).
- ; Unfortunately, we can't do the "blend" transfer mode *and* mask the
- ; operation to the icon's mask in a single operation unless we first convert
- ; the icon's mask into a region.
- ; A multiple-operation approach is possible, but since that involves
- ; creating a third bitmap, we must then worry about the GDevice and
- ; maxGDevice. Also, of course, it's slower.
- ; So, instead, we perform the blend by modifying the color table of
- ; the temporary CIcon we've just constructed. Then, we use CopyMask to
- ; place the appropriate portion of the icon on screen.
- ;
- ; If the icon is selected, the selected icon color is the BackColor.
- ;
-
- ; Okay, we know we want to blend. Now, change the color table.
- moveq.l #0,d2 ; Get SelColor's red in D2
- move curBackColor(a4),d2
- moveq.l #0,d3 ; Get SelColor's green in D3
- move curBackColor+2(a4),d3
- moveq.l #0,d4 ; Get SelColor's blue in D4
- move curBackColor+4(a4),d4
-
- move.l scratchCtab(a4),a1 ; get handle to scratch ctab
- move.l (a1),a1 ; pointer
- move 6(a1),d0 ; Get ctSize field
- lea 10(a1),a1 ; Point a1 at first RGBColor
- @2:
- moveq.l #0,d1 ; Get color table's red
- move (a1),d1
- add.l d2,d1 ; Add "our" red
- asr.l #1,d1 ; divide by two
- move d1,(a1) ; write it back
-
- moveq.l #0,d1 ; Get color table's green
- move 2(a1),d1
- add.l d3,d1 ; Add "our" green
- asr.l #1,d1 ; divide by two
- move d1,2(a1) ; write it back
-
- moveq.l #0,d1 ; Get color table's blue
- move 4(a1),d1
- add.l d4,d1 ; Add "our" blue
- asr.l #1,d1 ; divide by two
- move d1,4(a1) ; write it back
-
- lea 8(a1),a1 ; bump pointer
- dbf d0,@2 ; and loop.
-
-
- ; Now that the color table's been suitably munged, we can go ahead and
- ; do the actual drawing. We use CopyMask so as to avoid transfer of the
- ; "stuff around the edges". Since we've changed the color table, this
- ; "stuff" is no longer white, and therefore a transfer operation which
- ; results in no-change for white source pixels is no longer useful.
- ;
- ; Notes:
- ; 1) Since we're using CopyMask, this drawing won't appear in printed
- ; output. Thus we would expect any selected icons to not appear in a
- ; PrintCatalog to LaserWriter 6.0. This doesn't actually appear to
- ; happen, however, perhaps because the Finder doesn't draw the icons
- ; in selected mode when printing.
- ; Anyway, if the bug ever does actually happen, it can be fixed
- ; easily by always drawing in the "unselected" mode first (using a
- ; CopyBits), and then drawing in this mode. However, this will slow
- ; down the drawing of selected icons.
- ;
- move.l scratchCicn(a4),a1 ; get handle to cicn
- move.l (a1),a1 ; get pointer to our pixMap
- move.l a1,-(sp) ; push pointer
-
- move.l scratchCicn(a4),a1 ; get handle to cicn again
- move.l (a1),a1 ; get pointer
- lea 50(a1),a1 ; bump pointer to mask BitMap
- move.l a1,-(sp) ; push mask BitMap address
-
- pea curPort(a4)
- _GetPort
- move.l curPort(a4),a1 ; get pointer to port
- lea 2(a1), a1 ; pointer to port's bitmap
- move.l a1,-(sp)
-
- move.l scratchCicn(a4),a1 ; get handle to cicn
- move.l (a1),a1 ; get pointer to cicn
- pea 6(a1) ; push pointer to bounds rect
-
- pea 56(a1) ; mask rect pointer %%% not checking size!
-
- move.l parm_rectptr(a6),-(sp) ; dest rect pointer
-
- _CopyMask
-
- bra PCBExit
-
- ; ================================================
- ; Unselected Icon: NewMul Color-table and CopyBits
- ; ================================================
- PCBCopyBits:
-
- ; We've determined that the icon is not selected. In this case, we want to
- ; do a "NewMul" operation on the color table and then CopyBits in transparent
- ; mode.
- ;
- ; NewMul is defined as follows:
- ; Color = SelColor + Color*(WHITE - SelColor)
- ; This calculation is carried out independently on each of the three components.
- ;
- ; If the icon is unselected, the selected icon color is the ForeColor.
- ;
- moveq.l #0,d2 ; Get SelColor's red in D2
- move curForeColor(a4),d2
- moveq.l #0,d3 ; Get SelColor's green in D3
- move curForeColor+2(a4),d3
- moveq.l #0,d4 ; Get SelColor's blue in D4
- move curForeColor+4(a4),d4
-
- move.l scratchCtab(a4),a1 ; get handle to scratch ctab
- move.l (a1),a1 ; pointer
- move 6(a1),d0 ; Get ctSize field
- lea 10(a1),a1 ; Point a1 at first RGBColor
- @2:
- moveq.l #0,d1 ; Get color table's red
- move (a1),d1
- not d2 ; Subtract the SelColor from FFFF
- mulu d2,d1 ; Multiply by color
- swap d1
- not d2 ; Restore original SelColor
- add d2,d1 ; And add it to the product.
- move d1,(a1) ; write it back
-
- moveq.l #0,d1 ; Get color table's green
- move 2(a1),d1
- not d3 ; Same calculation
- mulu d3,d1
- swap d1
- not d3
- add d3,d1
- move d1,2(a1) ; write it back
-
- moveq.l #0,d1 ; Get color table's blue
- move 4(a1),d1
- not d4 ; Same calculation
- mulu d4,d1
- swap d1
- not d4
- add d4,d1
- move d1,4(a1) ; write it back
-
- lea 8(a1),a1 ; bump pointer
- dbf d0,@2 ; and loop.
-
-
- ; ============================
- ; Ready now to do the CopyBits
- ; ============================
- PCBSetupCB:
- move.l scratchCicn(a4),a1 ; get handle to cicn
- move.l (a1),-(sp) ; push pointer to src bits
-
- pea curPort(a4)
- _GetPort
- move.l curPort(a4),a1 ; get pointer to port
- lea 2(a1), a1 ; pointer to port's bitmap
- move.l a1, -(sp)
-
- move.l scratchCicn(a4),a1 ; get handle to cicn
- move.l (a1),a1 ; get pointer to cicn
- lea 6(a1), a1 ; pointer to bounds rect
- move.l a1,-(sp)
-
- move.l parm_rectptr(a6),-(sp) ; dest rect pointer
-
- move #36, -(sp) ; push mode (transparent)
- clr.l -(sp) ; no mask
- _CopyBits
-
- PCBGiveUp:
- PCBExit:
-
- RESTORE_ALL
- STACK_END
-
- whiteRGB dc.w $ffff, $ffff, $ffff
- blackRGB dc.w 0, 0, 0
- grayRGB dc.w $8000, $8000, $8000
-
-
- ; end of IconPatch.asm
-
-